﻿using Model;
using Model.UserInfos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL.Userinfos
{
    public class UserinfoDal : IUserinfoDal
    {
        private readonly MS_Context context;

        public UserinfoDal(MS_Context context)
        {
            this.context = context;
        }

        /// <summary>
        /// 查询用户名
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public UserInfo GetUserName(string userName)
        {
            return context.UserInfos.Where(x => x.UserName == userName || x.UserPhone == userName || x.Email == userName).FirstOrDefault();           
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public UserInfo Create(UserInfo m)
        {
            context.UserInfos.Add(m);
            context.SaveChanges();
            return m;
        }

        public int Delete(int id)
        {
            throw new NotImplementedException();
        }

        public IQueryable<UserInfo> QueryAll()
        {
            throw new NotImplementedException();
        }

        public List<UserInfo> GetAll()
        {
            throw new NotImplementedException();
        }

        public UserInfo Queryable(int id)
        {
            throw new NotImplementedException();
        }
    }
}
